<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      7.3.&nbsp;Customizing the /etc/hosts File
    </title>
    <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="lfs" id="lfs-7.3">
    <div class="navheader">
      <h4>
        Linux From Scratch - Version 7.3
      </h4>
      <h3>
        Chapter&nbsp;7.&nbsp;Setting Up System Bootscripts
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="network.html" title=
          "General Network Configuration">Prev</a>
          <p>
            General Network Configuration
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="udev.html" title=
          "Device and Module Handling on an LFS System">Next</a>
          <p>
            Device and Module Handling on an LFS System
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="chapter07.html" title=
          "Chapter&nbsp;7.&nbsp;Setting Up System Bootscripts">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Linux From Scratch - Version 7.3">Home</a>
        </li>
      </ul>
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="ch-scripts-hosts" name="ch-scripts-hosts"></a>7.3. Customizing
        the /etc/hosts File
      </h1>
      <p>
        If a network card is to be configured, decide on the IP address,
        fully-qualified domain name (FQDN), and possible aliases for use in
        the <code class="filename">/etc/hosts</code> file. The syntax is:
      </p>
      <pre class="screen">
<code class="literal">IP_address myhost.example.org aliases</code>
</pre>
      <p>
        Unless the computer is to be visible to the Internet (i.e., there is
        a registered domain and a valid block of assigned IP
        addresses&mdash;most users do not have this), make sure that the IP
        address is in the private network IP address range. Valid ranges are:
      </p>
      <pre class="screen">
<code class="literal">Private Network Address Range      Normal Prefix
10.0.0.1 - 10.255.255.254           8
172.x.0.1 - 172.x.255.254           16
192.168.y.1 - 192.168.y.254         24</code>
</pre>
      <p>
        x can be any number in the range 16-31. y can be any number in the
        range 0-255.
      </p>
      <p>
        A valid private IP address could be 192.168.1.1. A valid FQDN for
        this IP could be lfs.example.org.
      </p>
      <p>
        Even if not using a network card, a valid FQDN is still required.
        This is necessary for certain programs to operate correctly.
      </p>
      <p>
        Create the <code class="filename">/etc/hosts</code> file by running:
      </p>
      <pre class="userinput">
<kbd class="command">cat &gt; /etc/hosts &lt;&lt; "EOF"
<code class="literal"># Begin /etc/hosts (network card version)

127.0.0.1 localhost
<em class="replaceable"><code>&lt;192.168.1.1&gt;</code></em> <em class=
"replaceable"><code>&lt;HOSTNAME.example.org&gt;</code></em> <em class=
"replaceable"><code>[alias1] [alias2 ...]</code></em>

# End /etc/hosts (network card version)</code>
EOF</kbd>
</pre>
      <p>
        The <em class="replaceable"><code>&lt;192.168.1.1&gt;</code></em> and
        <em class=
        "replaceable"><code>&lt;HOSTNAME.example.org&gt;</code></em> values
        need to be changed for specific uses or requirements (if assigned an
        IP address by a network/system administrator and the machine will be
        connected to an existing network). The optional alias name(s) can be
        omitted.
      </p>
      <p>
        If a network card is not going to be configured, create the
        <code class="filename">/etc/hosts</code> file by running:
      </p>
      <pre class="userinput">
<kbd class="command">cat &gt; /etc/hosts &lt;&lt; "EOF"
<code class="literal"># Begin /etc/hosts (no network card version)

127.0.0.1 <em class=
"replaceable"><code>&lt;HOSTNAME.example.org&gt;</code></em> <em class=
"replaceable"><code>&lt;HOSTNAME&gt;</code></em> localhost

# End /etc/hosts (no network card version)</code>
EOF</kbd>
</pre>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="network.html" title=
          "General Network Configuration">Prev</a>
          <p>
            General Network Configuration
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="udev.html" title=
          "Device and Module Handling on an LFS System">Next</a>
          <p>
            Device and Module Handling on an LFS System
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="chapter07.html" title=
          "Chapter&nbsp;7.&nbsp;Setting Up System Bootscripts">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Linux From Scratch - Version 7.3">Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
